import axiosInstance from "../axiosInstance";

const User = {
    //登录
    checkLogin(phone, password) {
        return axiosInstance.get('/login/cellphone', {
            params: { phone, password }
        })
    },
    //退出登录
    logout() {
        return axiosInstance.get('/logout')
    },



    // 注册  1.看该手机是否已经注册 没注册的话
    //       2.需要验证码，得发验证码
    //       3.先判断验证码是否正确再进行注册


    //检测手机号码是否已注册
    isRegister(phone) {
        return axiosInstance.get('/cellphone/existence/check', {
            params: { phone }
        })
    },

    //发送验证码
    sendCaptcha(phone) {
        return axiosInstance.get('/captcha/sent', {
            params: { phone }
        })
    },

    //注册
    register(captcha, phone, password, nickname) {
        return axiosInstance.get('/register/cellphone', {
            params: { captcha, phone, password, nickname }
        })
    },

    //更新头像

    uploadUserPhoto(file) {
        let formData = new FormData();
        formData.append('imgFile', file);
        return axiosInstance.post('/avatar/upload', formData, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    }


}

export default User;